<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>get</button>
</body>
<script>
    var btn = document.querySelector("button");

    btn.onclick = function () {

        // 以get方式传递数据时, 会将参数数据队列拼接到url之后, 以 ? 分隔
        // 参数数据队列:  a=1&b=2&c=3

        var wd = ""; //查询所有数据
        var col = "id"; //默认按编号排序
        var type = "asc"; //升序
        var page = 1; //第一页
        var size = 10;


        var xhr = new XMLHttpRequest(); // 0

        xhr.open("get", `http://43.138.81.225/demo/php/searchGradeOrderLimit.php?wd=${wd}&col=${col}&type=${type}&page=${page}&size=${size}`, true);

        xhr.send();

        xhr.onreadystatechange = function () {
            // 2  3  4
            console.log("readyState:", xhr.readyState);
            if (xhr.readyState == 4 && xhr.status == 200) {
                var result = xhr.responseText;
                result = JSON.parse(result);
                console.log(result);
            }
        }
    }




</script>

</html>